//
//  YTRootViewController.m
//  CllForIOS
//
//  Created by 杨涛涛 on 2018/3/5.
//  Copyright © 2018年 aRui. All rights reserved.
//

#import "YTRootViewController.h"

@interface YTRootViewController ()

@end

@implementation YTRootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.navigationController.navigationBar setHidden:YES];
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    [self createRootNav];
    
}

- (void)createRootNav
{
    CGFloat height = (SCREEN_H == 812.0 ? 44 : 20);
    self.statusView = [WSUITools createViewWithFrame:CGRectMake(0, 0, SCREEN_W, height)];
    self.statusView.backgroundColor = [UIColor  whiteColor];
    [self.view addSubview:self.statusView];
    self.topView = [WSUITools createViewWithFrame:CGRectMake(0, height, SCREEN_W, 49)];
    self.topView.backgroundColor = [UIColor whiteColor];
    self.topView.userInteractionEnabled = YES;
    [self.view addSubview:self.topView];
    //
    self.lineView = [[UIView alloc]init];
    self.lineView.backgroundColor = RGBA(230, 230, 230);
    [self.topView addSubview:self.lineView];
    self.lineView.frame=CGRectMake(0, 44, CGRectGetWidth(self.topView .frame), 0.5);
    
    
    //左ima按钮
    self.leftimaBtn =[[UIButton alloc]initWithFrame:CGRectMake(5, 18, 20, 20)];
    
    [self.leftimaBtn setImage:IMAGE(@"back") forState:UIControlStateNormal];
//    [self.leftButton addTarget:self action:@selector(leftEvents) forControlEvents:UIControlEventTouchUpInside];
    [self.topView addSubview:self.leftimaBtn];
   
    //左按钮
    self.leftButton = [WSUITools createButtonWithFrame:CGRectMake(CGRectGetMaxX(self.leftimaBtn.frame), 18, 60, 20)
                                                 title:@""
                                            titleColor:[UIColor blackColor]
                                                 image:@""
                                   backgroundImageName:nil target:nil selector:nil];
//  [self.leftButton layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleLeft imageTitleSpace:5];
    [self.leftButton setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
//    [self.leftButton addTarget:self action:@selector(leftEvents) forControlEvents:UIControlEventTouchUpInside];
    [self.topView addSubview:self.leftButton];
    
    
    self.leftallBtn =[[UIButton alloc]initWithFrame:CGRectMake(5, 18, 80, 20)];
    [self.leftallBtn addTarget:self action:@selector(leftEvents) forControlEvents:UIControlEventTouchUpInside];
    [self.topView addSubview:self.leftallBtn];
    
    //标题
    self.titleLabel =[[UILabel alloc]init];
    self.titleLabel.textColor = RGBA(245, 28, 134);
    self.titleLabel.font = KFONT_medium(17);
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    [self.topView addSubview:self.titleLabel];
     
    self.titleLabel.frame=CGRectMake(50, 18, 100, 20);
    CGPoint center= self.titleLabel.center;
    center.x=SCREEN_W/2;
    self.titleLabel.center=center;
    //右按钮
    self.rightButton = [[UIButton alloc]init];
    [self.topView addSubview:self.rightButton];
    self.rightButton.frame=CGRectMake(SCREEN_W-50, 18, 30, 20);

}

- (void)addRightTarget:(SEL)selector
{
    [self.rightButton addTarget:self action:selector forControlEvents:UIControlEventTouchUpInside];
}

- (void)addLeftTarger:(SEL)selector
{
  
    [self.leftallBtn addTarget:self action:selector forControlEvents:UIControlEventTouchUpInside];
    
}

-(void)leftEvents{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)dealloc{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}
@end
